package com.proxy.dynamicProxy;

public class DynamicProxyTest {
    public static void main(String[] args) {
        //创建目标对象
        ITeacherDao target = new TeacherDao();
        //通过工厂给目标对象创建代理对象
        ProxyFactory proxyFactory = new ProxyFactory(target);
        ITeacherDao proxyInstance = (ITeacherDao)proxyFactory.getProxyInstance();
        proxyInstance.teach();
        String name = proxyInstance.checkName("小明");

        //从输出的结果可以看到proxyInstance 是一个代理对象
        //proxyInstanceclass com.sun.proxy.$Proxy0
        System.out.println("proxyInstance"+proxyInstance.getClass());

    }
}
